﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Direct.Web.Mvc.Controls2;
using Direct.ApplicationModel;

namespace Direct.Server.Modules.Shell.Controls
{
    public class ShellDefaultNavigationPart : UiWidget<ShellDefaultNavigationPart>
    {
        protected override void Init()
        {
            base.Init();
            this.AddClass("shell-menu-nav-part");
            this.Add(new UiTitle()
                .SetTextBinding("Caption")
                .SetBinding(UiTitle.SubtitleProperty, "Hint"));
            this.New<UiList>()
                .AddClass("items-holder ui-corner-all")
                .SetBinding(UiList.ItemsSourceProperty, "Items")
                .SetItemTemplate(new UListItem().Set(tmpl =>
                {
                    tmpl.Add(new UiLink()
                        .AddClass("link")
                        .ConfigHasState()
                        .SetBinding(UiLink.HrefProperty, "Url")
                        .SetBinding(UiLink.IdProperty, "Id", "mi_{0}")
                        .SetBinding(UiLink.LinkBehaviorProperty, "Behavior")
                        .Add(new Html.Span().AddClass("ui-icon ui-icon-circle-plus").SetRenderEnabledBinding("Items.Count:not-empty"))
                        .Add(new Html.Span().AddClass("ui-icon ui-icon-circle-arrow-e").SetRenderEnabledBinding("Items.Count:empty"))
                        .AddText("", bindingPath: "Caption", cssClass: "text")
                        .AddText("", bindingPath: "Hint", cssClass: "hint"));
                }));

        }
    }
}
